package Controller.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Model.Newtons;
import View.MainView;

public class NewtonsListener implements ActionListener {

	private MainView view;
	private Newtons model;
	
	public NewtonsListener() {
		view = null;
		model = null;
	}
	
	public NewtonsListener(MainView view, Newtons model) {
		this.view = view;
		this.model = model;
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		model.clearList();
		view.resetNewtons();
		model.setValues(view.getNX(), view.getNIteration(), view.getNFunction(), view.getNThreshold());
		model.computeNewtons();
		view.setModelNewton(model.getxList(), model.getyList(), model.getyPrimeList(), model.getThresholdList(), model.getTrueXList(), model.getTrueYList());
		view.updateNewtonsChart();
	}

}
